package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.RoleBean;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService service;

    @RequestMapping("findAll")
    public List<RoleBean> findAll(){
        return service.findAll();
    }

    @RequestMapping("cutAll")
    public PageInfo<RoleBean> cutAll(int pageNO){
        return service.cutAll(pageNO);
    }

    @RequestMapping("add")
    public String addRole(RoleBean role,int[] gradeArray){
        service.addRole(role, gradeArray);
        return "ok";
    }

    @RequestMapping("del")
    public String delRole(int id){
        service.delRole(id);
        return "ok";
    }


    @RequestMapping("findById")
    public RoleBean findById(int id){
        return service.findById(id);
    }

    @RequestMapping("update")
    public String updateRoleGrade(int id,int[] gradeArray){
        service.updateRoleGrade(id, gradeArray);
        return "ok";
    }
}
